<?php
namespace YunCangChu\Controller;
use Think\Controller;
class PublicController extends Controller {
    //我的
    public function _initialize(){
        //已加盟
        //$this->LoginID = '15210088045';
        //$this->LoginID     = '15210088045';
        //未加盟
        //$this->LoginID = '18624044772';
        //$this->LoginID = '18519775375';
        $this->LoginID = Cookie('LoginID');
        if($this->LoginID == '')
        {
            $this->redirect('login/index');
        }
    }
    //图片上传
    public function upload(){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     0 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录
        // 上传单个文件
        $info   =   $upload->uploadOne($_FILES['upfile']);
        if(!$info) {// 上传错误提示错误信息
            return json_encode(array('code'=>'404','msg'=>$upload->getError()));
        }else{// 上传成功 获取上传文件信息

            return json_encode(array('code'=>'200','src'=> $info['savepath'].$info['savename']));
        }
    }
}